#include <cstdio>
using namespace std;

int main()
{
	int test;
	scanf("%d", &test);
	while (test--) {
		int len, n;
		scanf("%d%d", &len, &n);
		int max = 0, min = 0;
		for (int i = 0; i < n; ++i) {
			int tmp;
			scanf("%d", &tmp);
			if (tmp << 1 < len) tmp = len - tmp;
			if (max < tmp) max = tmp;
			if (min < len - tmp) min = len - tmp;
		}
		printf("%d %d\n", min, max);
	}
	return 0;
}
